package com.lbw.config;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;


public class Md5 {

    /**
     * md5加秘
     * @param data
     */
    public static StringBuilder md5Encryption(String data) {
        StringBuilder result = null;
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(data.getBytes(StandardCharsets.UTF_8));
            byte[] m = md5.digest();
            result = new StringBuilder();
            for (byte b : m) {
                result.append(Integer.toHexString((0x000000ff & b) | 0xffffff00).substring(6));
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return result;
    }
}
